import { useEffect, useState, useRef } from 'react';
import { SongWrapper } from './index.styled';
import { getUserSubCount } from '../../../api/user';

const SongList = () => {
    /**
     * 在 react18 中 useEffect 会执行两次
     * 当发起网络请求时如果不想执行两次可以设置缓存机制
     */
    let cache = useRef(null);
    useEffect(() => {
        let ignore = false;
        getUserSubCount().then((res) => {
            console.log('🚀 ~ file: index.tsx:11 ~ getUserSubCount ~ res:', res);
            value.current = res.data;
            // }
        });
        return () => {
            // ignore = true;
            value.current = {};
        };
    }, []);

    return <SongWrapper></SongWrapper>;
};

export default SongList;
